package cn.yuxiaoyuan.fallback;

import cn.yuxiaoyuan.feign.RuleFeignApi;
import cn.yuxiaoyuan.pojo.DistanceDto;
import cn.yuxiaoyuan.result.JSONResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author solargen
 * @version 1.0
 * @date 2025/6/28 15:19
 */
@Component
public class RuleFeignApiFallback implements FallbackFactory<RuleFeignApi> {
    @Override
    public RuleFeignApi create(Throwable cause) {
        return new RuleFeignApi() {
            @Override
            public JSONResult price(DistanceDto distanceDto) {
                return JSONResult.error("服务调用失败");
            }

            @Override
            public JSONResult getBaseRule() {
                return JSONResult.error("服务调用失败");
            }
        };
    }
}
